package ar.com.cema.methodology.analyzer.ui.servlet.json;

import java.util.Set;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import ar.com.cema.methodology.analyzer.model.Person;
import ar.com.cema.methodology.analyzer.services.SurveyService;
import ar.com.cema.methodology.analyzer.ui.ServiceLocator;

@WebServlet(name="PersonJsonProviderServlet", urlPatterns = { ServiceLocator.JSON_PERSON_MP }) 
public class PersonJsonProviderServlet extends JsonProviderServlet {
	private static final long serialVersionUID = 677666319152485634L;

	@Autowired
	private SurveyService surveyService;
	
	public void setSurveyService(SurveyService surveyService) {
		this.surveyService = surveyService;
	}

	@Override
	protected String getJSON(HttpServletRequest request) {
		Set<Person> personSet = surveyService.listInterviewees();
		return gson.toJson(personSet);
	}
}